home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / psychic5.c < prev    next >
Text File  |  2000-04-04  |  19KB  |  622 lines

  1. /**************************
  2.  *** PSYCHIC 5 hardware ***        (by Roberto Ventura)
  3.  **************************
  4.  
  5.  
  6. Psychic 5 (c) JALECO (early 1987)
  7.  
  8. driver by Jarek Parchanski
  9.  
  10.  
  11. 0) GENERAL.
  12.  
  13. The game has two Z80s.
  14. The second CPU controls the two YM2203 sound chips.
  15. Screen resolution is 224x256 (vertical CRT).
  16. 768 colors on screen.
  17. 96 sprites (16x16 or 32x32).
  18.  
  19. Some hardware features description is arbitrary since I
  20. guessed their hardware implementation trusting what
  21. I can recall of the 'real' arcade game.
  22.  
  23.  
  24. 1) ROM CONTENTS.
  25.  
  26. P5A    256 Kbit    Sound program ROM
  27. P5B    512 Kbit    Sprites data ROM 0
  28. P5C    512 Kbit    Sprites data ROM 1
  29. P5D    256 Kbit    Main CPU program ROM
  30. P5E    512 Kbit    Banked CPU data ROM (banks 0,1,2 and 3)
  31. P5F    256 Kbit    Foreground data ROM
  32. P5G    512 Kbit    Background data ROM 0
  33. P5H    512 Kbit    Background data ROM 1
  34.  
  35. ROM banks 2 and 3 contain the eight level maps only.
  36.  
  37. Graphics format is pretty simple,each nibble contains information
  38. for one pixel (4 planes packed).
  39.  
  40. All graphics is made of 8x8 tiles (32 consecutive bytes),16x16 tiles
  41. are composed of 4 consecutive 8x8 tiles,while 32x32 sprites can be
  42. considered as four 16x16 tiles assembled in the same way 8x8 tiles produce
  43. one 16x16 tile.
  44. Tile composition follows this scheme:
  45.  
  46. These are 4 consecutive tiles as stored in ROM - increasing memory
  47. (the symbol ">" means the tiles are rotated 270 degrees):
  48.  
  49. A>;B>;C>;D>
  50.  
  51. This is the composite tile.
  52.  
  53. A> C>
  54. B> D>
  55.  
  56. This is the way tile looks on the effective CRT after 90 deg rotation.
  57.  
  58. C^ D^
  59. A^ B^
  60.  
  61.  
  62. 2) CPU.
  63.  
  64. The board mounts two crystals, 12.000 Mhz and 5.000 Mhz.
  65. The possible effective main CPU clock may be 6 Mhz (12/2).
  66.  
  67. The main Z80 runs in Interrupt mode 0 (IM0),the game program expects
  68. execution of two different restart (RST) instructions.
  69. RST 10,the main IRQ,is to be triggered each time the screen is refreshed.
  70. RST 08 must be triggered in order to make the game work properly
  71. (e.g. demo game),I guess sound has something to do with this IRQ,but I
  72. don't know whether it is sinchronized with video beam neither I know whether
  73. it can be disabled.
  74.  
  75. Sound CPU runs in IM1.
  76.  
  77. The main CPU lies idle waiting the external IRQ occurrence executing code
  78. from 012d to 0140.
  79.  
  80. Game data is paged,level maps and other data fit in ROM space
  81. 8000-bfff.
  82.  
  83. Video RAM is also banked at locations from c000 to dfff.
  84.  
  85.  
  86.  
  87. 3) MAIN CPU MEMORY MAP.
  88.  
  89. 0000-7fff       ROM
  90. 8000-bfff       paged ROM
  91. c000-dfff       paged RAM (RAM/VRAM/IO)
  92. f000-f1ff    I/O
  93. f200-f7ff    Sprites registers (misc RAM)
  94. f800-ffff       Work RAM
  95.  
  96. -paged RAM memory map
  97.  
  98. Bank 0
  99.  
  100. c000-cfff    Background tile buffer
  101. e000-dfff    RAM (dummy background image for software collisions)
  102.  
  103. Bank 1
  104.  
  105. c000-c3ff    I/O
  106. c400-cbff    Palette RAM
  107. d000-d800    Foreground tile buffer
  108.  
  109.  
  110. 4) I/O
  111.  
  112. -VRAM bank 1
  113.  
  114. c000    COIN SLOTS and START BUTTONS
  115.  
  116.         76543210
  117.         ||    ||
  118.         ||    |^-- coin 1
  119.         ||    ^--- coin 2
  120.         ||
  121.         |^-------- start 1
  122.         ^--------- start 2
  123.  
  124.  
  125. c001    PLAYER 1 CONTROLS
  126. c002    PLAYER 2 CONTROLS
  127.  
  128.         76543210
  129.           ||||||
  130.           |||||^-- right
  131.           ||||^--- left
  132.           |||^---- down
  133.           ||^----- up
  134.           |^------ fire 0
  135.           ^------- fire 1
  136.  
  137.  
  138. c003    DIPSWITCH 0
  139.  
  140.         76543210
  141.         ||
  142.         ^^-------- number of player's espers
  143.  
  144.  
  145. c004    DIPSWITCH 1
  146.  
  147.         76543210
  148.         |||    |
  149.         |||    ^-- player's immortality
  150.         ^^^------- coin/credit configurations
  151.  
  152. c308    BACKGROUND SCROLL Y  least significant 8 bits
  153.  
  154. c309    BACKGROUND SCROLL Y  most significant 2 bits
  155.  
  156.     76543210
  157.           ||
  158.           |^-- Y scroll bit 8
  159.           ^--- Y scroll bit 9
  160.  
  161. c30A    BACKGROUND SCROLL X  least significant 8 bits
  162.  
  163. c30B    BACKGROUND SCROLL X  MSB
  164.  
  165.     76543210
  166.     ||||||||
  167.     |||||||^-- X scroll bit 8
  168.     ||||||^--- Unknown (title screen)
  169.     ^^^^^^---- Unknown (title screen: 0xff)
  170.  
  171. c30C    SCREEN MODE
  172.  
  173.     76543210
  174.           ||
  175.           |^-- background enable bit (0 means black BG)
  176.           ^--- grey background enable bit
  177.  
  178. c5fe    BACKGROUND PALETTE INTENSITY (red and green)
  179.  
  180.     76543210
  181.     ||||||||
  182.     ||||^^^^-- green intensity
  183.     ^^^^------ red intensity
  184.  
  185. c5ff    BACKGROUND PALETTE INTENSITY (blue)
  186.  
  187.     76543210
  188.     ||||||||
  189.         ||||^^^^-- unknown (?)
  190.     ^^^^------ blue intensity
  191.  
  192. -RAM f000-f1ff
  193.  
  194. f000    SOUND COMMAND (?)
  195.  
  196. f001    UNKNOWN
  197.     maybe some external HW like a flashing light
  198.     when a coin falls in slot (?)
  199.  
  200. f002    ROM PAGE SELECTOR
  201.     select four (0-3) ROM pages at 8000-bfff.
  202.  
  203. f003    VRAM PAGE SELECTOR
  204.     selects two (0-1) VRAM pages at c000-dfff.
  205.  
  206. f004    UNKNOWN
  207.  
  208. f005    UNKNOWN
  209.  
  210.  
  211. 5) COLOR RAM
  212.  
  213. The palette system is dynamic,the game can show up to 768 different
  214. colors on screen.
  215.  
  216. Each color component (RGB) depth is 4 bits,two consecutive bytes are used
  217. for each color code (12 bits).
  218.  
  219. format: RRRRGGGGBBBB0000
  220.  
  221. Colors are organized in palettes,since graphics is 4 bits (16 colors)
  222. each palette takes 32 bytes;the three different layers (background,sprites
  223. and foreground) don't share any color,each has its own 256 color space,hence
  224. the 768 colors on screen.
  225.  
  226. c400-c5ff       Sprites palettes
  227. c800-c9ff       Background palettes
  228. ca00-cbff       Foreground palettes
  229.  
  230. The last palette colors for sprites and foreground are transparent
  231. colors,these colors aren't displayed on screen so the actual maximum
  232. color output is 736 colors.
  233.  
  234. Some additional palette effects are provided for background.
  235. Sprite palette 15's transparent color (c5fe-c5ff) is the global
  236. background intensity.
  237. Background Intensity is encoded in the same way of colors,and
  238. affects the intensity of each color component (BGR).
  239. The least significant nibble of c5ff is unknown,it assumes value
  240. 0xf occasionaly when the other nibbles are changed.The only
  241. value which is not 0 neither 0xf is 2 and it is assumed by this nibble
  242. during the ride on the witches' broom.
  243.  
  244. When bit 1 of c30c (VRAM bank 1) is set background screen turns
  245. grey.Notice the output of this function is passed to the palette
  246. intensity process.
  247. When you hit the witch the screen gets purple,this is done via
  248. setting grey screen and scaling color components.
  249. (BTW,I haven't seen a Psychic5 machine for about 10 years but
  250. I think the resulting purple tonality in my emulator is way off...)
  251.  
  252. Palette intensity acts badly during title screen,when the game
  253. scenario rapidly shows up under the golden logo;the problem is value
  254. 0xffff causes the background to be displayed as black.
  255.  
  256.  
  257. 6) TILE-BASED LAYERS
  258.  
  259. The tile format for background and foreground is the same,the
  260. only difference is that background tiles are 16x16 pixels while foreground
  261. tiles are only 8x8.
  262.  
  263. Background virtual screen is 1024 pixels tall and 512 pixel wide.
  264.  
  265. Two consecutive bytes identify one tile.
  266.  
  267.         O7 O6 O5 O4 O3 O2 O1 O0         gfx Offset
  268.         O9 O8 FX FY C3 C2 C1 C0         Attibute
  269.  
  270.         O= GFX offset (1024 tiles)
  271.         F= Flip X and Y
  272.         C= Color palette selector
  273.  
  274. Tile layers are to be displayed 'bottom-up' (eg. c000-c040
  275. is row 63 of background screen)
  276.  
  277. Both background and foreground playfields can scroll; background tiles
  278. are arranged in a rotational (wrap-around) buffer; window can be scrolled
  279. vertically by an eight pixel offset (i.e. enough to scroll a single tile
  280. smoothly),the game has to copy in new tiles every time a row is scrolled
  281. (this feature is only used in the credits section at the end of the game).
  282. I haven't provided the address for this feature, since I don't
  283. know where it is mapped.
  284.  
  285.  
  286. 7) SPRITES
  287.  
  288. Five bytes identify each sprite,but the registers actually used
  289. are placed at intervals of 16.
  290. The remaining bytes are used as backup sprite coordinates and
  291. attributes,not real sprites.
  292. Sprites are provided in 2 different sizes,16x16 and 32x32.
  293. Larger sprites are addressed as 16x16 sprites,but they are all
  294. aligned by 4.
  295.  
  296. The first sprite data is located at f20b,then f21b and so on.
  297.  
  298. 0b      X7 X6 X5 X4 X3 X2 X1 X0         X coord (on screen)
  299. 0c      Y7 Y6 Y5 Y5 Y3 Y2 Y1 Y0         X coord (on screen)
  300. 0d      O9 O8 FX FY SZ X8 -- Y8         hi gfx - FLIP - hi X - hi Y
  301. 0e      O7 O6 O5 O4 O3 O2 O1 O0         gfx - offset
  302. 0f      -- -- -- -- C3 C2 C1 C0         color
  303.  
  304.     Y= Y coordinate (two's complemented) (Y8 is used to clip sprite on top border)
  305.         X= X coordinate (X8 is used to clip 32x32 sprites on left border)
  306.         O= Gfx offset (1024 sprites)
  307.         F= Flip
  308.     SZ=Size 0=16x16 sprite,1=32x32 sprite
  309.         C= Color palette selector
  310. */
  311.  
  312. #include "driver.h"
  313. #include "vidhrdw/generic.h"
  314.  
  315. void psychic5_init_machine(void);
  316. int  psychic5_vh_start(void);
  317. void psychic5_vh_stop(void);
  318. void psychic5_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  319. WRITE_HANDLER( psychic5_paged_ram_w );
  320. READ_HANDLER( psychic5_paged_ram_r );
  321. WRITE_HANDLER( psychic5_vram_page_select_w );
  322. READ_HANDLER( psychic5_vram_page_select_r );
  323.  
  324.  
  325. static int psychic5_bank_latch = 0x0;
  326.  
  327.  
  328. READ_HANDLER( psychic5_bankselect_r )
  329. {
  330.     return psychic5_bank_latch;
  331. }
  332.  
  333. WRITE_HANDLER( psychic5_bankselect_w )
  334. {
  335.     unsigned char *RAM = memory_region(REGION_CPU1);
  336.     int bankaddress;
  337.  
  338.     if (data != psychic5_bank_latch)
  339.     {
  340.         psychic5_bank_latch = data;
  341.         bankaddress = 0x10000 + ((data & 3) * 0x4000);
  342.         cpu_setbank(1,&RAM[bankaddress]);     /* Select 4 banks of 16k */
  343.     }
  344. }
  345.  
  346. int psychic5_interrupt(void)
  347. {
  348.     if (cpu_getiloops() == 0)
  349.        return 0xd7;        /* RST 10h */
  350.     else
  351.           return 0xcf;        /* RST 08h */
  352. }
  353.  
  354.  
  355. static struct MemoryReadAddress readmem[] =
  356. {
  357.     { 0x0000, 0x7fff, MRA_ROM },
  358.     { 0x8000, 0xbfff, MRA_BANK1 },
  359.     { 0xc000, 0xdfff, psychic5_paged_ram_r },
  360.     { 0xe000, 0xefff, MRA_RAM },
  361.     { 0xf000, 0xf000, MRA_RAM },
  362.     { 0xf001, 0xf001, MRA_RAM },            // unknown
  363.     { 0xf002, 0xf002, psychic5_bankselect_r },
  364.     { 0xf003, 0xf003, psychic5_vram_page_select_r },
  365.     { 0xf004, 0xf004, MRA_RAM },            // unknown
  366.     { 0xf005, 0xf005, MRA_RAM },            // unknown
  367.     { 0xf006, 0xf1ff, MRA_NOP },
  368.     { 0xf200, 0xf7ff, MRA_RAM },
  369.     { 0xf800, 0xffff, MRA_RAM },
  370.     { -1 }    /* end of table */
  371. };
  372.  
  373. static struct MemoryWriteAddress writemem[] =
  374. {
  375.     { 0x0000, 0x7fff, MWA_ROM },
  376.     { 0x8000, 0xbfff, MWA_BANK1 },
  377.     { 0xc000, 0xdfff, psychic5_paged_ram_w },
  378.     { 0xe000, 0xefff, MWA_RAM },
  379.     { 0xf000, 0xf000, soundlatch_w },
  380.     { 0xf001, 0xf001, MWA_RAM },            // unknown
  381.     { 0xf002, 0xf002, psychic5_bankselect_w },
  382.     { 0xf003, 0xf003, psychic5_vram_page_select_w },
  383.     { 0xf004, 0xf004, MWA_RAM },            // unknown
  384.     { 0xf005, 0xf005, MWA_RAM },            // unknown
  385.     { 0xf006, 0xf1ff, MWA_NOP },
  386.     { 0xf200, 0xf7ff, MWA_RAM, &spriteram, &spriteram_size },
  387.     { 0xf800, 0xffff, MWA_RAM },
  388.     { -1 }    /* end of table */
  389. };
  390.  
  391. static struct MemoryReadAddress sound_readmem[] =
  392. {
  393.     { 0x0000, 0x7fff, MRA_ROM },
  394.     { 0xc000, 0xc7ff, MRA_RAM },
  395.     { 0xe000, 0xe000, soundlatch_r },
  396.     { -1 }
  397. };
  398.  
  399. static struct MemoryWriteAddress sound_writemem[] =
  400. {
  401.     { 0x0000, 0x7fff, MWA_ROM },
  402.     { 0xc000, 0xc7ff, MWA_RAM },
  403.     { -1 }
  404. };
  405.  
  406. static struct IOWritePort sound_writeport[] =
  407. {
  408.     { 0x00, 0x00, YM2203_control_port_0_w },
  409.     { 0x01, 0x01, YM2203_write_port_0_w },
  410.     { 0x80, 0x80, YM2203_control_port_1_w },
  411.     { 0x81, 0x81, YM2203_write_port_1_w },
  412.     { -1 }
  413. };
  414.  
  415. INPUT_PORTS_START( psychic5 )
  416.     PORT_START
  417.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  418.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
  419.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
  420.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
  421.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  422.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  423.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
  424.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
  425.  
  426.     PORT_START        /* player 1 controls */
  427.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  428.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  429.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  430.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
  431.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
  432.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
  433.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  434.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  435.  
  436.     PORT_START        /* player 2 controls */
  437.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  438.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_COCKTAIL )
  439.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_COCKTAIL )
  440.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_COCKTAIL )
  441.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  442.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  443.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  444.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  445.  
  446.     PORT_START  /* dsw0 */
  447.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
  448.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  449.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  450.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
  451.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  452.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  453.     PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
  454.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  455.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  456.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Difficulty ) )
  457.     PORT_DIPSETTING(    0x08, "Normal" )
  458.     PORT_DIPSETTING(    0x00, "Hard" )
  459.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Cabinet ) )
  460.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  461.     PORT_DIPSETTING(    0x10, DEF_STR( Cocktail ) )
  462.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
  463.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  464.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  465.     PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) )
  466.     PORT_DIPSETTING(    0x80, "2" )
  467.     PORT_DIPSETTING(    0xc0, "3" )
  468.     PORT_DIPSETTING(    0x40, "4" )
  469.     PORT_DIPSETTING(    0x00, "5" )
  470.  
  471.     PORT_START  /* dsw1 */
  472.     PORT_BITX(    0x01, 0x01, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE )
  473.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  474.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  475.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  476.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  477.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  478.     PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_A ) )
  479.     PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
  480.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  481.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_1C ) )
  482.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
  483.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_1C ) )
  484.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )
  485.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_3C ) )
  486.     PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
  487.     PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_B ) )
  488.     PORT_DIPSETTING(    0x00, DEF_STR( 5C_1C ) )
  489.     PORT_DIPSETTING(    0x04, DEF_STR( 4C_1C ) )
  490.     PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
  491.     PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )
  492.     PORT_DIPSETTING(    0x1c, DEF_STR( 1C_1C ) )
  493.     PORT_DIPSETTING(    0x18, DEF_STR( 1C_2C ) )
  494.     PORT_DIPSETTING(    0x14, DEF_STR( 1C_3C ) )
  495.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_4C ) )
  496. INPUT_PORTS_END
  497.  
  498.  
  499.  
  500. static struct GfxLayout charlayout =
  501. {
  502.     8,8,    /* 8x8 characters */
  503.     1024,    /* 1024 characters */
  504.     4,      /* 4 bits per pixel */
  505.     { 0, 1, 2, 3 }, /* the four bitplanes for pixel are packed into one nibble */
  506.     { 0, 4, 8, 12, 16, 20, 24, 28 },
  507.     { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
  508.     32*8       /* every char takes 32 consecutive bytes */
  509. };
  510.  
  511. static struct GfxLayout spritelayout =
  512. {
  513.     16,16,  /* 16x16 characters */
  514.     1024,    /* 1024 characters */
  515.     4,      /* 4 bits per pixel */
  516.     { 0, 1, 2, 3 },    /* the four bitplanes for pixel are packed into one nibble */
  517.     { 0, 4, 8, 12, 16, 20, 24, 28, 64*8, 64*8+4, 64*8+8, 64*8+12, 64*8+16, 64*8+20, 64*8+24, 64*8+28 },
  518.     { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8, 32*8, 36*8, 40*8, 44*8, 48*8, 52*8, 56*8, 60*8 },
  519.     128*8    /* every char takes 128 consecutive bytes */
  520. };
  521.  
  522. static struct GfxDecodeInfo gfxdecodeinfo[] =
  523. {
  524.     { REGION_GFX1, 0, &spritelayout,  0*16, 16 },
  525.     { REGION_GFX2, 0, &spritelayout, 16*16, 16 },
  526.     { REGION_GFX3, 0, &charlayout,   32*16, 16 },
  527.     { -1 } /* end of array */
  528. };
  529.  
  530.  
  531.  
  532. static void irqhandler(int irq)
  533. {
  534.     cpu_set_irq_line(1,0,irq ? ASSERT_LINE : CLEAR_LINE);
  535. }
  536.  
  537. static struct YM2203interface ym2203_interface =
  538. {
  539.     2,        /* 2 chips   */
  540.     6000000/4,        /* 1.5 MHz */
  541.     { YM2203_VOL(50,15), YM2203_VOL(50,15) },
  542.     { 0 },
  543.     { 0 },
  544.     { 0 },
  545.     { 0 },
  546.     { irqhandler }
  547. };
  548.  
  549. static struct MachineDriver machine_driver_psychic5 =
  550. {
  551.     /* basic machine hardware */
  552.     {
  553.         {
  554.             CPU_Z80,
  555.             6000000,
  556.             readmem,writemem,0,0,
  557.             psychic5_interrupt,2
  558.         },
  559.         {
  560.             CPU_Z80 | CPU_AUDIO_CPU,
  561.             6000000,
  562.             sound_readmem,sound_writemem,0,sound_writeport,
  563.             ignore_interrupt,0    /* IRQs are generated by the YM2203 */
  564.         }
  565.     },
  566.     53.8, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  567.     /* frames per second hand tuned to match game and music speed */
  568.     10,                                     /* Allow time for 2nd cpu to interleave*/
  569.     psychic5_init_machine,
  570.     /* video hardware */
  571.     32*8, 32*8,
  572.     { 0*8, 32*8-1, 2*8, 30*8-1 },
  573.     gfxdecodeinfo,
  574.     48*16,48*16,
  575.     0,
  576.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  577.     0,
  578.     psychic5_vh_start,
  579.     psychic5_vh_stop,
  580.     psychic5_vh_screenrefresh,
  581.  
  582.     /* sound hardware */
  583.     0,0,0,0,
  584.     {
  585.         {
  586.             SOUND_YM2203,
  587.             &ym2203_interface
  588.         }
  589.     }
  590. };
  591.  
  592.  
  593. /***************************************************************************
  594.  
  595.   Game driver(s)
  596.  
  597. ***************************************************************************/
  598.  
  599. ROM_START( psychic5 )
  600.     ROM_REGION( 0x20000, REGION_CPU1 )                 /* 2*64K for main CPU, Z80 */
  601.     ROM_LOAD( "p5d",          0x00000, 0x08000, 0x90259249 )
  602.     ROM_LOAD( "p5e",          0x10000, 0x10000, 0x72298f34 )
  603.  
  604.     ROM_REGION( 0x10000, REGION_CPU2 )                 /*64K for 2nd z80 CPU*/
  605.     ROM_LOAD( "p5a",          0x00000, 0x08000, 0x50060ecd )
  606.  
  607.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  608.     ROM_LOAD( "p5b",          0x00000, 0x10000, 0x7e3f87d4 )    /* sprite tiles */
  609.     ROM_LOAD( "p5c",          0x10000, 0x10000, 0x8710fedb )
  610.  
  611.     ROM_REGION( 0x20000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  612.     ROM_LOAD( "p5g",          0x00000, 0x10000, 0xf9262f32 )    /* background tiles */
  613.     ROM_LOAD( "p5h",          0x10000, 0x10000, 0xc411171a )
  614.  
  615.     ROM_REGION( 0x08000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  616.     ROM_LOAD( "p5f",          0x00000, 0x08000, 0x04d7e21c )    /* foreground tiles */
  617. ROM_END
  618.  
  619.  
  620.  
  621. GAMEX( 1987, psychic5, 0, psychic5, psychic5, 0, ROT270, "Jaleco", "Psychic 5", GAME_NO_COCKTAIL )
  622.